<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>视频播放 - 初中生作品展</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
            background: #000;
            color: white;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
        }

        .header {
            background: rgba(0, 0, 0, 0.8);
            padding: 20px;
            border-bottom: 1px solid #333;
        }

        .header-content {
            max-width: 1200px;
            margin: 0 auto;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .back-button {
            background: #007bff;
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 5px;
            cursor: pointer;
            font-size: 14px;
            transition: background 0.3s;
        }

        .back-button:hover {
            background: #0056b3;
        }

        .video-info {
            text-align: center;
        }

        .video-title {
            font-size: 1.5rem;
            margin-bottom: 5px;
        }

        .video-meta {
            font-size: 0.9rem;
            color: #ccc;
        }

        .main-content {
            flex: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 20px;
        }

        .video-container {
            max-width: 1000px;
            width: 100%;
            background: #000;
            border-radius: 10px;
            overflow: hidden;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
        }

        .video-player {
            width: 100%;
            position: relative;
        }

        .video-player video {
            width: 100%;
            height: auto;
            display: block;
        }

        .video-details {
            padding: 20px;
            background: rgba(255, 255, 255, 0.05);
        }

        .video-details h2 {
            font-size: 1.8rem;
            margin-bottom: 10px;
            color: white;
        }

        .video-details p {
            color: #ccc;
            margin-bottom: 5px;
            font-size: 1rem;
        }

        .video-details .duration {
            color: #007bff;
            font-weight: bold;
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .header-content {
                flex-direction: column;
                gap: 15px;
            }

            .video-title {
                font-size: 1.2rem;
            }

            .video-details h2 {
                font-size: 1.4rem;
            }

            .main-content {
                padding: 10px;
            }
        }

        @media (max-width: 480px) {
            .header {
                padding: 15px;
            }

            .video-title {
                font-size: 1rem;
            }

            .video-details {
                padding: 15px;
            }

            .video-details h2 {
                font-size: 1.2rem;
            }
        }
    </style>
</head>
<body>
    <header class="header">
        <div class="header-content">
            <button class="back-button" onclick="goBack()">← 返回作品展</button>
            <div class="video-info">
                <div class="video-title" id="videoTitle">加载中...</div>
                <div class="video-meta" id="videoMeta">加载中...</div>
            </div>
            <div></div> <!-- 占位符，保持布局平衡 -->
        </div>
    </header>

    <main class="main-content">
        <div class="video-container">
            <div class="video-player">
                <video controls autoplay id="videoPlayer">
                    <source id="videoSource" src="" type="video/mp4">
                    您的浏览器不支持视频播放。
                </video>
            </div>
            <div class="video-details">
                <h2 id="detailTitle">加载中...</h2>
                <p>作者：<span id="detailAuthor">加载中...</span></p>
                <p>班级：<span id="detailClass">加载中...</span></p>
                <p>时长：<span id="detailDuration" class="duration">加载中...</span></p>
            </div>
        </div>
    </main>

    <script>
        // 页面加载完成后初始化
        document.addEventListener('DOMContentLoaded', function() {
            loadVideoInfo();
        });

        // 加载视频信息
        function loadVideoInfo() {
            try {
                const videoInfo = JSON.parse(localStorage.getItem('videoInfo'));
                
                if (videoInfo) {
                    // 设置视频源
                    const videoPlayer = document.getElementById('videoPlayer');
                    const videoSource = document.getElementById('videoSource');
                    videoSource.src = videoInfo.src;
                    videoPlayer.load();

                    // 设置页面标题
                    document.title = `${videoInfo.title} - 初中生作品展`;

                    // 设置头部信息
                    document.getElementById('videoTitle').textContent = videoInfo.title;
                    document.getElementById('videoMeta').textContent = `${videoInfo.author} | ${videoInfo.className} | ${videoInfo.duration}`;

                    // 设置详细信息
                    document.getElementById('detailTitle').textContent = videoInfo.title;
                    document.getElementById('detailAuthor').textContent = videoInfo.author;
                    document.getElementById('detailClass').textContent = videoInfo.className;
                    document.getElementById('detailDuration').textContent = videoInfo.duration;
                } else {
                    showError('未找到视频信息');
                }
            } catch (error) {
                console.error('加载视频信息失败:', error);
                showError('加载视频信息失败');
            }
        }

        // 显示错误信息
        function showError(message) {
            document.getElementById('videoTitle').textContent = '错误';
            document.getElementById('videoMeta').textContent = message;
            document.getElementById('detailTitle').textContent = '错误';
            document.getElementById('detailAuthor').textContent = message;
            document.getElementById('detailClass').textContent = '请返回重试';
            document.getElementById('detailDuration').textContent = '';
        }

        // 返回上一页
        function goBack() {
            if (window.opener) {
                window.close();
            } else {
                window.history.back();
            }
        }

        // 键盘快捷键
        document.addEventListener('keydown', function(event) {
            switch(event.key) {
                case 'Escape':
                    goBack();
                    break;
                case ' ':
                    // 空格键播放/暂停
                    event.preventDefault();
                    const video = document.getElementById('videoPlayer');
                    if (video.paused) {
                        video.play();
                    } else {
                        video.pause();
                    }
                    break;
            }
        });

        // 视频错误处理
        document.getElementById('videoPlayer').addEventListener('error', function() {
            showError('视频加载失败，请检查文件路径');
        });
    </script>
</body>
</html>
